<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 20. Troubleshooting</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="appendixes.html" title="Part IV. Appendixes">
<link rel="prev" href="appendixes.html" title="Part IV. Appendixes">
<link rel="next" href="tips.html" title="Chapter 21. Tips &amp; Tricks">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Chapter 20. Troubleshooting</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="appendixes.html">Prev</a> </td>
<th width="60%" align="center">Part IV. Appendixes</th>
<td width="20%" align="right"> <a accesskey="n" href="tips.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="chapter" title="Chapter 20. Troubleshooting">
<div class="titlepage"><div><div><h2 class="title">
<a name="troubleshooting"></a>Chapter 20. Troubleshooting</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl><dt><span class="sect1"><a href="troubleshooting.html#smarty.php.errors">Smarty/PHP errors</a></span></dt></dl>
</div>
<p></p>
<div class="sect1" title="Smarty/PHP errors">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="smarty.php.errors"></a>Smarty/PHP errors</h2></div></div></div>
<p>
    Smarty can catch many errors such as missing tag attributes
    or malformed variable names. If this happens, you will see an error
    similar to the following:
   </p>
<div class="example">
<a name="id467350"></a><p class="title"><b>Example 20.1. Smarty errors</b></p>
<div class="example-contents"><pre class="screen">

Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah'
       in /path/to/smarty/Smarty.class.php on line 1041

Fatal error: Smarty: [in index.tpl line 28]: syntax error: missing section name
       in /path/to/smarty/Smarty.class.php on line 1041

    </pre></div>
</div>
<br class="example-break"><p>
    Smarty shows you the template name, the line number and the error.
    After that, the error consists of the actual line number in the Smarty
    class that the error occured.
   </p>
<p>
    There are certain errors that Smarty cannot catch, such as missing
    close tags. These types of errors usually end up in PHP compile-time
    parsing errors.
   </p>
<div class="example">
<a name="id467515"></a><p class="title"><b>Example 20.2. PHP parsing errors</b></p>
<div class="example-contents"><pre class="screen">

Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75

    </pre></div>
</div>
<br class="example-break"><p>
    When you encounter a PHP parsing error, the error line number will
    correspond to the compiled PHP script, NOT the template itself. Usually
    you can look at the template and spot the syntax error. Here are some
    common things to look for: missing close tags for
    <a class="link" href="language.function.if.html" title="{if},{elseif},{else}"><code class="varname">{if}{/if}</code></a> or
    <a class="link" href="language.function.if.html" title="{if},{elseif},{else}"><code class="varname">{section}{/section}</code>
    </a>, or syntax of logic within an <code class="varname">{if}</code> tag. If you
    can't find the error, you might have to open the compiled PHP file and
    go to the line number to figure out where the corresponding error is in
    the template.
   </p>
<div class="example">
<a name="id467806"></a><p class="title"><b>Example 20.3. Other common errors</b></p>
<div class="example-contents">
<pre class="screen">

Warning: Smarty error: unable to read resource: "index.tpl" in...
or
Warning: Smarty error: unable to read resource: "site.conf" in...

</pre>
<p>
    </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
      The <a class="link" href="variable.template.dir.html" title="$template_dir">
      <em class="parameter"><code>$template_dir</code></em></a> is incorrect, doesn't exist or
      the file <code class="filename">index.tpl</code> is not in the
      <code class="filename">templates/</code> directory
      </p></li>
<li class="listitem"><p>
        A <a class="link" href="language.function.config.load.html" title="{config_load}">
        <code class="varname">{config_load}</code></a>
        function is within a template (or
        <a class="link" href="api.config.load.html" title="configLoad()"><code class="varname">configLoad()</code></a>
        has been called) and either
        <a class="link" href="variable.config.dir.html" title="$config_dir"><em class="parameter"><code>$config_dir</code></em>
        </a>  is incorrect, does not exist or
        <code class="filename">site.conf</code> is not in the directory.
        </p></li>
</ul></div>
<p>
    </p>
<pre class="screen">

Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist,
or is not a directory...

    </pre>
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
    Either the
    <a class="link" href="variable.compile.dir.html" title="$compile_dir">
    <em class="parameter"><code>$compile_dir</code></em></a>is incorrectly set,
    the directory does not exist, or <code class="filename">templates_c</code> is a
    file and not a directory.
    </p></li></ul></div>
<pre class="screen">

Fatal error: Smarty error: unable to write to $compile_dir '....

    </pre>
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
    The <a class="link" href="variable.compile.dir.html" title="$compile_dir">
   <em class="parameter"><code>$compile_dir</code></em></a> is not writable by the web server.
   See the bottom of the
    <a class="link" href="installing.smarty.basic.html" title="Basic Installation">installing smarty</a> page
    for more about permissions.
    </p></li></ul></div>
<pre class="screen">

Fatal error: Smarty error: the $cache_dir 'cache' does not exist,
or is not a directory. in /..

    </pre>
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
    This means that
    <a class="link" href="variable.caching.html" title="$caching">
    <em class="parameter"><code>$caching</code></em></a> is enabled and either;
    the
    <a class="link" href="variable.cache.dir.html" title="$cache_dir"><em class="parameter"><code>$cache_dir</code></em></a>
    is incorrectly set, the directory does not exist,
    or <code class="filename">cache/</code> is a
    file and not a directory.
    </p></li></ul></div>
<pre class="screen">

Fatal error: Smarty error: unable to write to $cache_dir '/...

    </pre>
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
    This means that
    <a class="link" href="variable.caching.html" title="$caching"><em class="parameter"><code>$caching</code></em></a> is
    enabled and the <a class="link" href="variable.cache.dir.html" title="$cache_dir">
    <em class="parameter"><code>$cache_dir</code></em></a>
    is not writable by the web server. See the bottom of the
    <a class="link" href="installing.smarty.basic.html" title="Basic Installation">installing smarty</a> page
    for permissions.
    </p></li></ul></div>
<pre class="screen">

Warning: filemtime(): stat failed for /path/to/smarty/cache/3ab50a623e65185c49bf17c63c90cc56070ea85c.one.tpl.php 
in /path/to/smarty/libs/sysplugins/smarty_resource.php

   </pre>
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
      This means that your application registered a custom error hander (using <a class="ulink" href="http://php.net/set_error_handler" target="_top">set_error_handler()</a>) 
      which is not respecting the given <code class="literal">$errno</code> as it should. If, for whatever reason, this is the desired behaviour of your custom
      error handler, please call <a class="link" href="api.mute.expected.errors.html" title="Smarty::muteExpectedErrors()"><code class="varname">muteExpectedErrors()</code></a> after you've registered your 
      custom error handler.
     </p></li></ul></div>
</div>
</div>
<br class="example-break"><p>
   See also
   <a class="link" href="chapter.debugging.console.html" title="Chapter 10. Debugging Console">debugging</a>.
   </p>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="appendixes.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="appendixes.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="tips.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Part IV. Appendixes </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> Chapter 21. Tips &amp; Tricks</td>
</tr>
</table>
</div>
</body>
</html>
